<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>填写订单信息</title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/Index/Common/css/head_end.css"/>
		<link rel="stylesheet" type="text/css" href="__ROOT__/Index/Common/css/order.css"/>
		<link rel="stylesheet" type="text/css" href="__ROOT__/Index/Common/css/order_form.css"/>
		<script type="text/javascript" src="__ROOT__/Index/Common/js/head_end.js"></script>
		<script type="text/javascript" src="__ROOT__/Index/Common/js/jquery-3.2.1.min.js"></script>
		<script type="text/javascript" src="__ROOT__/Index/Common/js/PCASClass.js"></script>
	</head>
	<body>
		<div class="head">
			<div class="header">
				<div class="pink_logo">
					<a href=""><img src="http://i1.mbscss.com/img/moonbasa/2014/02/25/logo.jpg" alt="" /></a>
				</div>
				<div class="practice"><span>9年品质保证</span>|<span>7天无条件退货</span>|</div>
				<div class="logininfo_outdiv">
					<div class="helpmsg">
						<span>|</span>
						<a href="">帮助中心</a>
						<a class="help_weixin lw_weixin_icon" href="">微信</a>
						<a class="help_mobile lw_mobile_icon" href="">手机版</a>
					</div>
					<div class="loginInfo">
						<?php if(!isset($_SESSION['uid'])): ?><a href="__APP__/Login/register">注册</a>
							<span style="color: #e8e8e8;">|</span>
							<a href="__APP__/Login/login">登录</a>
							<span>欢迎光临梦芭莎!</span>
							<?php else: ?>
							<span>欢迎光临梦芭莎!</span>
							您好,<a class="_username" href="javascript:void(0)"><?php echo (session('email')); ?></a><?php endif; ?>
					</div>
				</div>
				<!----------------------------我的购物车--》填写订单--》订单提交成功   这里雪碧图-->
				<div class="stepby stepby1"></div>
			</div>
		</div>
		<div class="order_form_min">
			<form class="formOrder" action="">
				<div class="orderbody">
					<div class="xxtitle">
						<span class="address_title"></span>
						<a class="change_dz change_sure" href="javascript:void(0)">[修改]</a>
						<a class="change_cancel change_dz display" href="javascript:void(0)">[取消修改]</a>
					</div>
					
					<!--收货信息(如果有)-->
					<div class="shouhuoxinxi">
						
					<div class="shouhuoxinxi clear">
						<div class="dizhi">
							<dl>
								<dd class="shdz_dz"></dd>
							</dl>
						</div>
					</div>
					
					<!--填写收货信息(没有收货地址)-->
					<div class="add_address display">
						<div class="newaddmsg">
							<div class="addsr">
								<div class="sh">
									<!--收货人-->
									<div class="shr">
										<div class="area_title"><span class="star">*</span>收货人:&nbsp;</div>
										<div class="area_con">
											<input class="input sh_name surely" type="text" placeholder="请填写准确真实收货人姓名" />
											<span class="check_write display">请您填写收货人姓名</span>
										</div>
									</div>
								</div>
								<div class="sh clear">
									<!--省市区-->
									<div class="area_title"><span class="star">*</span>选择地区:&nbsp;</div>
									<div class="area_con">
										<select class="province surely" name="province3"></select>
										<select class="city surely" name="city3"></select>
										<select class="area surely" name="area3"></select>
									</div>
								</div>
								<div class="sh">
									<!--详细地址-->
									<div class="area_title"><span class="star">*</span>详细地址:&nbsp;</div>
										<div class="area_con">
											<input class="input xx_addr surely" type="text" placeholder="请填写收货人详细地址" />
											<span class="check_write display">请输入长度大于4个字符的详细地址</span>
										</div>
								</div>
								<div class="sh">
									<!--邮政编码-->
									<div class="area_title"><span class="star">*</span>邮政编码:&nbsp;</div>
									<div class="area_con">
										<input class="input postcode surely" type="text" placeholder="请填写收货人邮政编码" />
										<span class="check_write display">请您填写邮政编码</span>
									</div>
								</div>
								<div class="sh">
									<!--电子邮箱-->
									<div class="area_title">电子邮箱:&nbsp;</div>
									<div class="area_con">
										<input class="input" type="text" placeholder="请填写电子邮箱" />
										<span class="check_write display"></span>
									</div>
								</div>
								<div class="sh">
									<!--手机-->
									<div class="area_title"><span class="star">*</span>手机:&nbsp;</div>
									<div class="area_con">
										<input class="input phone_num surely" type="text" placeholder="请填写手机号码" />
										<span class="check_write display">请填写手机号码</span>
									</div>
								</div>
								<div class="sh">
									<!--电话-->
									<div class="area_title">电话:&nbsp;</div>
									<div class="area_con">
										<input class="input" type="text" placeholder="请填写电话号码" />
										<span class="check_write display"></span>
									</div>
								</div>
								<div class="addsure">
									
									<!--确定提交-->
									<a class="addsure_btn" href="javascript:void(0)">确定</a>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				<!--支付及配送方式-->
				<div class="zfps">
					<div class="zftitle">
						<span class="pay-title"></span>
						<a class="zf_change zf_change_sure" href="javascript:void(0)">[修改]</a>
						<a class="zf_change zf_change_cancel display" href="javascript:void(0)">[取消修改]</a>
					</div>
					<div class="zf_con">
						<div class="pay_defualt pay">您选择使用 <span class="pay_module red_txt">货到付款(现金支付)</span><br /><span class="red_txt"><?php echo ($total_num); ?>样商品:</span><span>梦芭莎快递运输</span></div>
						<div class="pay_edit_con pay display">
							<div class="zffs">
								<div class="zffs2">
									<div class="zhifu">
										<div class="zhifutitle">支付方式</div>
										<div class="zhifu_nr">
											<p class="xz1">
												<span><input id="input" class="payWay" value="货到付款(现金支付)" checked="checked" name="pay_edit" type="radio" /></span>
												<span>货到付款<font>送货上门后再收款，支持现金POS机 </font></span>
											</p>
										</div>
										<div class="zhifu_nr2">
											<p class="xz1">
												<span><input id="input" class="payWay" value="在线支付" name="pay_edit" type="radio" /></span>
												<span>在线支付<font>即时到账，支持绝大多数银行借记卡及部分银行信用卡 </font></span>
											</p>
										</div>
										<div class="zhifu_nr3">
											<p class="xz1">
												<span><input id="input" class="payWay" value="线下银行电汇" name="pay_edit" type="radio" /></span>
												<span>线下银行电汇<font>通过银行柜员机或ATM机汇款 </font></span>
											</p>
										</div>
									</div>
									<div class="peisong">
										<div class="peisongtitle">配送方式： 快递送货上门</div>
										<div class="peisongqr">
											<a href="javascript:void(0)" class="sure_psbtn">确定支付及配送方式</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
				<div class="spxx_sh">
					<div class="show_list">
						<div class="xxtitle">
							<span class="shop_title"></span>
							<a class="cart_back" href="__URL__/index">返回修改购物车>></a>
						</div>
						<div class="shop_list_con">
							<div class="shop_list">
								<div class="shopmsg">
									<span class="sp_left">以下商品由 梦芭莎 发货<span class="yunfei">免配送费</span></span>
									<span class="sp_right"></span>
								</div>
								<table class="godds_block">
									<tbody>
										<tr>
											<th class="w_635">商品名称</th>
											<th class="w_117">梦芭莎价</th>
											<th class="w_120">数量</th>
											<th class="w_144">小计</th>
										</tr>
                                        <!--循环商品-->
                                        <?php if(is_array($orders)): $i = 0; $__LIST__ = $orders;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$orders): $mod = ($i % 2 );++$i;?><tr>
                                                <td class="clear">
                                                    <div class="fl m_l65 t_al">
                                                        <a href=""><img src="<?php echo ($orders["img"]); ?>" width="39" height="53" alt="" /></a>
                                                    </div>
                                                    <div class="fl m_l10 t_al">
                                                        <a class="goods_link" href=""><?php echo ($orders["name"]); ?></a>
                                                        <p>品牌：梦芭莎　尺寸：<?php echo ($orders["size"]); ?>　颜色：<?php echo ($orders["color"]); ?></p>
                                                    </div>
                                                </td>
                                                <td>
                                                    <span class="price_icon">￥</span>
                                                    <span class="price_num"><?php echo ($orders["price"]); ?>.00</span>
                                                </td>
                                                <td class="jianshu"><?php echo ($orders["num"]); ?></td>
                                                <td>
                                                    <span class="redcolor">￥</span>
                                                    <span class="redcolor small_count"><?php echo ($orders["total"]); ?>.00</span>
                                                </td>
                                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>

									</tbody>
								</table>
							</div>
							<div class="zonge">
								<div class="zg_right">
									<table class="money_block">
										<tbody>
											<tr>
												<td class="td_w1 t_ar"><b>商品总价</b>:</td>
												<td class="td_w2 t_ar"><span class="redcolor">￥</span><span class="redcolor m_zj"><?php echo ($all_total); ?>.00</span></td>
											</tr>
											<tr>
												<td class="td_w1 t_ar"><b>配送费</b>:</td>
												<td class="td_w2 t_ar"><span class="redcolor">免配送费</span></td>
											</tr>
											<tr>
												<td class="td_w1 t_ar"><b>应付金额</b>:</td>
												<td class="td_w2 t_ar"><span class="redcolor f_big">￥</span><span class="redcolor f_big m_zj"><?php echo ($all_total); ?>.00</span></td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="invoice_con">
						<div class="order_line">
							<div class="queren">
								<span><a href="javascript:void(0)" class="submit_btn" onclick="sub()">提交订单</a></span>
								<span class="tx">请核对以上信息，确认无误后点击"提交订单"</span>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
		
		
		<div class="foot">
			<div class="footer">
			<div class="info">
				<div class="infos clear">
					<ul>
						<li class="title">
							<a href="">新手指南</a>
						</li>
						<li>
							<a href="">注册新用户</a>
						</li>
						<li>
							<a href="">如何订购</a>
						</li>
						<li>
							<a href="">如何修改订单</a>
						</li>
						<li>
							<a href="">尺码对照表</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">支付方式</a>
						</li>
						<li>
							<a href="">支付方式</a>
						</li>
						<li>
							<a href="">账户体现及退款时效</a>
						</li>
						<li>
							<a href="">查看账户余额</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">配送方式</a>
						</li>
						<li>
							<a href="">配送费收取标准</a>
						</li>
						<li>
							<a href="">配送范围及配送时效</a>
						</li>
						<li>
							<a href="">签收注意事项</a>
						</li>
						<li>
							<a href="">海外订购</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">退换货服务</a>
						</li>
						<li>
							<a href="">退换货政策</a>
						</li>
						<li>
							<a href="">退换货流程</a>
						</li>
						<li>
							<a href="">隐私申明</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">会员制度及优惠</a>
						</li>
						<li>
							<a href="">优惠活动</a>
						</li>
						<li>
							<a href="">VIP优惠尊享</a>
						</li>
						<li>
							<a href="">大宗购物</a>
						</li>
						<li>
							<a href="">积分制度</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">帮助中心</a>
						</li>
						<li>
							<a href="">忘记密码</a>
						</li>
						<li>
							<a href="">常见问题</a>
						</li>
						<li>
							<a href="">在线客服</a>
						</li>
						<li>
							<a href="">联系我们</a>
						</li>
					</ul>
					<ul>
						<li class="title">
							<a href="">咨询订购</a>
						</li>
						<font>400-716-2828</font>
						<li class="title">
							<a href="">客户服务</a>
						</li>
						<font>400-716-7878</font>
					</ul>
					<ul>
						<li>
							<!--微信二维码-->
							<img src="http://i0.mbscss.com/img/moonbasa/2015/mobile/M4_14_150441.png" alt="" />
						</li>
					</ul>
				</div>
			</div>
			<div class="f_info">
				<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/top_1.jpg" alt="" />
				<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/top_2.jpg" alt="" />
				<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/top_3.jpg" alt="" />
				<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/top_4.jpg" alt="" />
			</div>
			<div class="foot_introduce">
				<div class="introduce">
					<a href="">首页</a>
					<a href="">公司简介</a>
					<a href="">旗下品牌</a>
					<a href="">零售店址</a>
					<a href="">梦芭莎网盟</a>
					<a href="">网店代理</a>
					<a href="">网站地图</a>
					<a href="">友情链接</a>
					<br /> Copyright © 2010-2019 梦芭莎官方网站，广州摩拉网络科技有限公司 All Rights Reserved 粤B2-20080069号
					<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/middle.png" alt="" /> 粤公网安备44010302000075
				</div>
				<div class="hzlogo">
					<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_1.jpg" alt="" />
					<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_2.jpg" alt="" />
					<span>
					<a href="http://netadreg.gzaic.gov.cn/ntmm/WebSear/WebLogoPub.aspx?logo=440105105022007080200053">
						<img style="width: 33px; height: 33px;" src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_3.jpg" alt="" />
					</a>
					<a href="http://weiquan.moonbasa.com/">
						<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_4.jpg" alt="" />
					</a>
				</span>
					<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_5.jpg" alt="" />
					<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_6.jpg" alt="" />
					<span class="youxin">
					<a href="http://www.ccredit.cn/zx/zxt.aspx?id=65">
						<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_7.jpg" alt="" />
					</a>
					<a href="https://search.szfw.org/cert/l/CX20120920001676001786?id=5">
						<img src="http://qxu1142120069.my3w.com/MoonBaSaImg/footer/bottom_8.jpg" alt="" />
					</a>
				</span>

				</div>
			</div>
		</div>
		</div>
	</body>
	<script type="text/javascript">
		new PCAS("province3","city3","area3");
		
		var address;
		var addressCode;
		var goodsMaster;
		var tel;
		//获取收货信息
		$.ajax({
			type:"post",
			url:"__URL__/get_addr",
			async:true,
			success:function(data){
				console.log(data);
				if(data['address1']){
					var str = data['sh_name']+"&nbsp;&nbsp;&nbsp;"+data['address1']+data['address2']+"&nbsp;&nbsp;&nbsp;"+data['postcode']+"&nbsp;&nbsp;&nbsp;"+data['phone_num']+"&nbsp;&nbsp;&nbsp;"+data['email'];
					$(".shdz_dz").html(str);
					address = data['address1']+data['address2'];
					addressCode = data['postcode'];
					goodsMaster = data['sh_name'];
					tel= data['phone_num'];
				}else{
					var str = "请填写收货地址！"
					$(".shdz_dz").html(str);
				}
				
			}
		});
		
		
		//点击修改收货地址
		$('.change_dz').click(function(){
			if($(this).hasClass('change_sure')){
				$(".add_address").removeClass('display');
			}
			if($(this).hasClass('change_cancel')){
				$(".add_address").addClass('display');
			}
			$('.change_dz').removeClass("display");
			$(this).addClass("display");
		})
		
		//点击修改支付方式
		$('.zf_change').click(function(){
			$('.pay').removeClass('display');
			$('.zf_change').removeClass("display");
			$(this).addClass("display");
//			console.log($('.pay').eq())
			if($(this).hasClass('zf_change_sure')){
				$('.pay').eq($(this).index()-1).addClass('display')
			}
			if($(this).hasClass('zf_change_cancel')){
				$('.pay').eq($(this).index()-1).addClass('display')
			}
			
		})
		
		//点击确定支付配送方式
		$('.sure_psbtn').click(function(){
			$('.pay').removeClass('display');
			$('.zf_change').removeClass("display");
			$('.zf_change_cancel').addClass('display');
			$('.pay_edit_con').addClass('display');
			$('.pay_module').html($("input[name='pay_edit']:checked").val());
		});
		
		$(".input").blur(function(){
//			
			var val = $(this).val();
			
			//如果是手机号码那个input,正则验证
			if($(this).hasClass('phone_num')){
				var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
				if(!myreg.test(val)){
					$(this).parent().find('.check_write').removeClass("display");
				}else{
					$(this).parent().find('.check_write').addClass("display");
				}
			}else if($(this).hasClass('postcode')){
				//邮编验证
				var myreg2=/[1-9]\d{5}(?!\d)/;
				if(!myreg2.test(val)){
					$(this).parent().find('.check_write').removeClass("display");
				}else{
					$(this).parent().find('.check_write').addClass("display");
				}
			}else if($(this).hasClass('xx_addr')){
				//详细地址验证
				if(val.length<=4){
					$(this).parent().find('.check_write').removeClass("display");
				}else{
					$(this).parent().find('.check_write').addClass("display");
				}
			}else if($(this).hasClass('sh_name')){
				if(val==""){
					$(this).parent().find('.check_write').removeClass("display");
				}else{
					$(this).parent().find('.check_write').addClass("display");
				}
			}
			
		});
		
		//确定提交收货信息
		$('.addsure_btn').click(function(){
			var sh_name = $('.sh_name').val();
			var address1 = $('.province').val()+$('.city').val()+$('.area').val();
			var address2 = $('.xx_addr').val();
//			var address = "123456";
			var postcode = $('.postcode').val();
			var phone_num = $('.phone_num').val();
			//判断验证是否通过
			$('.check_write').each(function(){
				if(!$(this).hasClass('display')){
					//验证不通过
					return false;
				}else if($('.surely').val()==""){
					return false;
				}else{
					//验证通过
					console.log("提交成功");
//					console.log(address);
					$.ajax({
						type:"post",
						url:"__URL__/addshxx",
						data:{
							sh_name,
							address1,
							address2,
							postcode,
							phone_num
						},
						dataType:"json",
						success:function(data){
							console.log(data);
							window.location.href='__APP__/Order/order_form_sub';
						}
					})
					return false;
				}
			})
			
		});
        function sub(){
		    var payWay = $('.pay_module').eq(0).text();
		    console.log(payWay);
            $.ajax({
                type:"POST",
                url:"__URL__/ordersSub",
                data:{
                    address,
                    tel,
                    addressCode,
                    goodsMaster,
                    payWay
                },
                dataType:'json',
                success:function(data){
                    console.log(data.status);
                    if(data.status==1){
                        location.href="__URL__/orderShow";
                    }
                },
                error:function (err) {
                    console.log(err);
                }
            })
        }
	</script>
</html>